<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 3/31/17
 * Time: 11:04 AM
 */

namespace common\models;

/**
 * Class GuaranteeCompany
 * @package common\models
 *
 * @property BankGuaranteeCompanyBind[] $bankGuaranteeCompanyBinds
 * @property Bank[] $banks
 * @property GuaranteeCompanyDotSite[] $guaranteeCompanyDotSites
 */
class GuaranteeCompany extends \common\models\base\GuaranteeCompany
{
    public static function getBySignCode($code)
    {
        return self::findOne(['sign_code'=>$code]);
    }

	/**
	 * @return \yii\db\ActiveQuery
	 */
	public function getBankGuaranteeCompanyBinds()
	{
		return $this->hasMany(BankGuaranteeCompanyBind::className(), ['guarantee_company_id' => 'id']);
	}
	
	/**
	 * @return \yii\db\ActiveQuery
	 */
	public function getBanks()
	{
		return $this->hasMany(Bank::className(), ['id' => 'bank_id'])->viaTable('{{%bank_guarantee_company_bind}}', ['guarantee_company_id' => 'id']);
	}
	
	/**
	 * @return \yii\db\ActiveQuery
	 */
	public function getGuaranteeCompanyDotSites()
	{
		return $this->hasMany(GuaranteeCompanyDotSite::className(), ['guarantee_company_id' => 'id']);
	}
}